Skip to content

fix: correct return types#340

Merged
gjtorikian merged 1 commit intomainfrom
doc-correct
Mar 6, 2026
Merged

fix: correct return types#340
gjtorikian merged 1 commit intomainfrom
doc-correct

Conversation

@gjtorikian
Copy link
Contributor

Description

This return types is not right.

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@gjtorikian gjtorikian requested review from a team as code owners March 6, 2026 21:26
@gjtorikian gjtorikian requested a review from mattgd March 6, 2026 21:26
@gjtorikian gjtorikian merged commit 0e9fb95 into main Mar 6, 2026
8 checks passed
@gjtorikian gjtorikian deleted the doc-correct branch March 6, 2026 21:27
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 6, 2026

Greptile Summary

This PR fixes an incorrect @return docblock on Webhook::verifyHeader(), changing it from @return bool true to @return string 'pass' if valid, otherwise an error message. The actual implementation has always returned strings ('pass', 'No Timestamp available', etc.), and the calling code in constructEvent checks for the string 'pass' — so the old docblock was simply wrong and could mislead developers or static analysis tools.

  • The corrected @return string accurately reflects all code paths in verifyHeader.
  • No logic, behaviour, or security implications are changed; this is a documentation-only fix.
  • The method lacks a native PHP : string return type hint. Adding one would reinforce the corrected docblock at the language level and provide runtime type enforcement.

Confidence Score: 5/5

  • This PR is safe to merge — it is a docblock correction with no behavioural changes.
  • The change is a one-line docblock correction that accurately reflects the method's actual return type. The method implementation and all callers remain untouched. Only the PHPDoc comment is modified, changing from an incorrect @return bool true to the correct @return string 'pass' if valid, otherwise an error message. No files require special attention.
  • No files require special attention

Sequence Diagram

sequenceDiagram
    participant Caller
    participant Webhook
    participant Resource_Webhook as Resource\Webhook

    Caller->>Webhook: constructEvent(sigHeader, payload, secret, tolerance)
    Webhook->>Webhook: verifyHeader(sigHeader, payload, secret, tolerance)
    Note over Webhook: Returns string: 'pass' or error message
    alt result == 'pass'
        Webhook->>Resource_Webhook: constructFromPayload(payload)
        Resource_Webhook-->>Webhook: Resource\Webhook object
        Webhook-->>Caller: Resource\Webhook
    else result is error string
        Webhook-->>Caller: string (error message)
    end
Loading

Last reviewed commit: 3403dff

* @return bool true
* @return string 'pass' if valid, otherwise an error message
*/
public function verifyHeader($sigHeader, $payload, $secret, $tolerance)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docblock now correctly documents the return type as string, but the method signature itself has no enforced PHP return type. Adding : string would make the contract machine-checkable and consistent with the corrected docblock.

Suggested change
public function verifyHeader($sigHeader, $payload, $secret, $tolerance)
public function verifyHeader($sigHeader, $payload, $secret, $tolerance): string

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant